<?php
	class BaseClass {
		//public
		public $Errors;

		//===================================================================================
		
		public function __construct() {
			$this->errors = array();
		}
		
		//===================================================================================
		
		public function setTextError($error) {
			$this->errors[] = $error;
		}

		//===================================================================================

		public function setError($error) {
			if (is_array($error)) {
				$this->errors = array_merge($this->errors, $error);
			} else {
				$this->errors[] = $error;
			}
		}

		//===================================================================================
		
		public function clearErrors() {
			$this->errors = array();
		}
		
		//===================================================================================
		
		public function isError() {
			if (!empty($this->errors)) return true;
			
			return false;
		}
				
		//===================================================================================
		
		public function getErrors() {
			if (empty($this->errors))
				return false;
			return $this->errors;
		}

		//===================================================================================

		public function GetErrorsAsText($implode_sign = "\n") {
			if (empty($this->errors))
				return "";

			return implode($implode_sign, $this->errors);
		}

		//===================================================================================
		
		public static function GetUploadError($error_code) {
			$return = false;
			switch($error_code)
			{
				case UPLOAD_ERR_INI_SIZE:
					$return = 'The uploaded file exceeds maximum file size';
				break;
				case UPLOAD_ERR_FORM_SIZE:
					$return = 'The uploaded file was only partially uploaded';
				break;
				case UPLOAD_ERR_NO_FILE:
					$return = 'No file was uploaded';
				break;
				case UPLOAD_ERR_NO_FILE:				
					$return = 'No file was uploaded';
				break;
				case UPLOAD_ERR_CANT_WRITE:
				case UPLOAD_ERR_NO_TMP_DIR:
				case UPLOAD_ERR_FORM_SIZE:
				case UPLOAD_ERR_EXTENSION:
					$return = 'Internal error';
				break;
			}
			return $return;
		}

		//===================================================================================

	}

?>
